<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    //成功调用
    public function success($data=[]){
        return response()->json([
            "code" => 200,
            "msg" => "请求成功",
            "data" => $data
        ]);
    }


    //失败调用
    public function error($code){
        return response()->json([
            "code" => $code,
            "msg" => config("fail.error")[$code]
        ]);
    }

    //列表调用
    public function jsondata($count=0,$data=[]){
        return response()->json([
            "code" => 0,
            "msg" => "ok",
            "count" => $count,
            "data" => $data
        ]);
    }
}
